<?php


if (!function_exists('build_luck')) {

    /**
     * 生成运气红包数据
     * @param number $num
     * @param number $amount
     * @return array
     */
    function build_luck($num, $money_total)
    {
    	return \app\common\service\Redpack::buildLuckPack($num, $money_total);
    }
}

if(!function_exists('getDistances')){

	function getDistances($lat1,$lng1,$lat2,$lng2){
	    if ($lat1 == $lat2 && $lng1 == $lng2) {
	        $s = 0;
	    } else {
	        $s = 6371.004*1000 * acos(cos($lat1*pi()/180)*cos($lat2*pi()/180)*cos(($lng2-$lng1)*pi()/180) + sin($lat1*pi()/180)*sin($lat2*pi()/180));
	    }
	    $distance = sprintf('%.1f', $s/1000);
	    return $distance;
	}
}

